﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Bjsubway.Xml;
using System.Xml.Linq;
using System.Xml;

namespace Bjsubway
{
    public partial class XmlTestForm : Form
    {
        public XmlTestForm()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            List<LineTime> ret = LineTime.GetLineTimeFromXml("linetime.xml");
            MessageBox.Show(ret.Count.ToString());
        }

        private void btnReadLinetime_Click(object sender, EventArgs e)
        {

            List<LineTime> ret = LineTime.GetLineTimeFromXml("linetime.xml");
            MessageBox.Show(ret.Count.ToString());
        }

        private void btnReadCdata_Click(object sender, EventArgs e)
        {
            string currentdir = Application.StartupPath;

            string lineTimeXmlPath = currentdir.Substring(0, currentdir.LastIndexOf("\\")) + "\\data\\" + "rule.xml";
            try
            {
                XDocument pList = XDocument.Load(lineTimeXmlPath);
                var linetime = from a in pList.Descendants("root").Elements("rule")
                               select new
                               {
                                   CData = a.Value
                               };
            
                MessageBox.Show(linetime.Count().ToString());
            }
            catch (Exception ex)
            {

            }
        }
       
    }
}
